<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <script type="text/javascript" src="scripts/boot.js"></script>
    <style type="text/css">
	.item{
		width: 95px;
		display: inline-block;
		margin-left: 5px;
	}
	</style>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
		<table style="width:100%;">
	        <tr>
	            <td style="width:30%;">
	             	<span class="item">订单编号(精确)：</span> <input id="serialNum" class="mini-textbox" emptyText="请输入订单编号" style="width:160px;" /> 
	            </td>
	            <td style="width:30%;">
	                <span class="item">物流公司(精确)：</span> <input id="expressId" emptyText="请选择..." class="mini-combobox" style="width:160px;" textField="name" valueField="id" url="orders_find_logistics.do" allowInput="false" showNullItem="true" nullItemText="全部"/>  
	            </td>
	            <td style="width:30%;">
	                <span class="item">收货人(精确)：</span> <input id="name" class="mini-textbox" emptyText="请输入收货人" style="width:160px;" />
	            </td>
	            <td style="display: inline-block;">&nbsp;</td>
	        </tr>
	        <tr>
	            <td>
	                <span class="item">审核时间(大于)：</span> <input id="startTime" emptyText="请选择..." class="mini-datepicker" style="width:160px;"
	        format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" allowInput="false"/>
	            </td>
	            <td>
	                <span class="item">审核时间(小于)：</span> <input id="endTime" emptyText="请选择..." class="mini-datepicker" style="width:160px;"
	        format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" allowInput="false"/>
	            </td>
	            <td>
	                <span class="item"> 下单时间(大于)：</span> <input id="createTime" emptyText="请选择..." class="mini-datepicker" style="width:160px;"
	        format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" allowInput="false"/>
	            </td>
	        </tr>
	        <tr> 
	            <td style="width:30%;">
	              <span class="item">系统：</span>
                  <input id="sysType" nullItemText="全部" emptyText="请选择..." class="mini-combobox" style="width:160px;" textField="keyValue" valueField="keyName" onvaluechanged="onDeptChanged" url="orders_find_system.do?keyType=DEPT_TYPE" showNullItem="true"/>         
                </td>
                <td style="width:30%;" colspan="2">
                  <span class="item">订单状态：</span>
                  <input id="orderStatus" class="mini-combobox" emptyText="请选择系统" style="width:160px;" textField="keyValue" valueField="keyName" /> 
	            </td>
	            <td style="display: inline-block;">
	                <a class="mini-button" iconCls="icon-search" onclick="search()">查询</a>
	            </td>
	        </tr>
	    </table>           
	</div>
	 <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
	    <table style="width:100%;">
	        <tr>
	       	 	<td style="width:100%;">
	       	 		<sec:authorize url='/order_find_export_current.do'>
                    <a class="mini-button" iconCls="icon-download" onclick="exportCurrent()">导出当前</a>
                    </sec:authorize>
                    <sec:authorize url='/orders_find_export_all.do'>
                    <a class="mini-button" iconCls="icon-download" onclick="exportAll()">导出全部</a>
                    </sec:authorize>
                </td>
	        </tr>
       	</table>
     </div>
     <div class="mini-fit" >
     <div id="datagrid1" class="mini-datagrid" allowCellWrap="true" idField="id" pageSize="20" url="all_orders_inquiry_view.do" style="width:100%; height:100%;">
		<div property="columns">
			<div type="indexcolumn"></div>
			<div field="serialNum" width="60" headerAlign="center" align="center">编号</div>
			<div field="createTime" width="130" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">下单时间</div>
			<div field="name" width="60" headerAlign="center" align="center" >收货人</div>
			<div header="各系统状态" headerAlign="center">
				<div property="columns">
					<div field="callStatus" width="60" headerAlign="center" align="center" >话务</div>
					<div field="ordersStatus" width="60" headerAlign="center" align="center" >订单</div>
					<div field="warehouseStatus" width="60" headerAlign="center" align="center" >仓储</div>
					<div field="financialStatus" width="60" headerAlign="center" align="center" >财务</div>
				</div>
			</div>
			<div field="contactNo" width="90" headerAlign="center" align="center" >联系电话</div>
			<div field="payment" width="60" headerAlign="center" align="center" >总金额</div>
			<div header="发货地址" headerAlign="center">
				<div property="columns">
					<div field="pName" width="80" headerAlign="center" align="center" >省</div>
					<div field="cName" width="80" headerAlign="center" align="center" >市</div>
					<div field="dName" width="80" headerAlign="center" align="center" >区</div>
					<div field="address" width="200" headerAlign="center" align="center" >详细地址</div>
				</div>
			</div>
			<div field="expressName" width="60" headerAlign="center" align="center" >物流公司</div>
			<div field="expressNo" width="70" headerAlign="center" align="center" >快递号</div>
			<div field="deliveryTime" width="130" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">发货时间</div>
			<div field="ordersProduct" width="150" headerAlign="center" align="center" >订单详细</div>
		</div>
	</div>
	</div>
	<div id="win1" class="mini-window" allowDrag="false" showHeader="false" title="选择地址—省份" style="width: 300px;height: 150px;">
	</div>
	<div id="win2" class="mini-window" allowDrag="false" showHeader="false" title="选择地址—省份" style="width: 300px;height: 150px;">
	</div>
<script type="text/javascript">
	mini.parse();
	var grid = mini.get("datagrid1");
	grid.load();
	
	//导出当前
	function exportCurrent(){
	 	var data = grid.data;
        var ids = [];
        $.each(data , function(){
            ids.push(this.id);
        });
        var id = ids.join(',');
        if(id) {
        	location.href="order_export_cur_all.do?id=" +id;
        }
	}
	
	//导出所有
	function exportAll(){
		var serialNum = mini.get("serialNum").getValue();
	    var expressId = mini.get("expressId").getValue();
	    var name = mini.get("name").getValue();
	    var c = mini.get("createTime").getFormValue();
	    var s = mini.get("startTime").getFormValue();
	    var e = mini.get("endTime").getFormValue();
		location.href="order_export_all_all.do?serialNum="+serialNum+"&expressId="+expressId+"&name="+name+"&stime="+c+"&startTime="+s+"&endTime="+e;
	}
	
	//订单信息查询
	function search() {
	    var serialNum = mini.get("serialNum").getValue();
	    var expressId = mini.get("expressId").getValue();
	    var name = mini.get("name").getValue();
	    var c = mini.get("createTime").getFormValue();
	    var s = mini.get("startTime").getFormValue();
	    var e = mini.get("endTime").getFormValue();
	    var sysType = mini.get("sysType").getValue();
	    var orderStatus = mini.get("orderStatus").getValue();
	    
	    grid.load({ serialNum: serialNum,
	    	expressId: expressId,
	    	name: name,
	    	stime: c,
	    	startTime: s,
	    	endTime: e,
	    	keyType: sysType,
	    	status: orderStatus
	    });
	}
	
    function ordersDetail(e){
    	var record = e.record;
    	return '<a style="width:150px;" href="javascript: ordersView('+record._uid+')">查看订单</a>';
    }
    
    function ordersView(row_uid) {
    	var row = grid.getRowByUID(row_uid);
        mini.open({
            url: "maintain_orders_detail_init.do",
            title: "查看订单", width: 850, height: 650,
            allowResize: false,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { row: row };
                iframe.contentWindow.SetData(data);
            },
            ondestroy: function (action) {
            	if(action == "cancel"){
            		mini.showMessageBox({
    	                title: "提示",
    	                showModal:false,
    	                iconCls: "mini-messagebox-info",
    	                message: "审核成功！",
    	                timeout: 3000,
    	                x: 'right',
    	                y: 'bottom',
    	            });
                	grid.reload();
	        	}
            }
        });
    }
    
	//查看订单跟踪信息
	function openTraceInformation(){
		var row = grid.getSelected();
		if(row){
			mini.open({
				url:"platform_cancel_trace_init.do",
				title: "跟踪信息", width: 570, height: 320,allowResize:false,
			 	onload: function () {
			 	  	 var iframe = this.getIFrameEl();
		 		  	 var data = {id: row.id};
			 		 iframe.contentWindow.SetData(data);
		        },
	       	});
		 }else{
			 
		 };
	}
	
 	// 弹出系统状态列表
    var sysType = mini.get("sysType");
    var orderStatus = mini.get("orderStatus");
    function onDeptChanged(e) {
        var keyName = sysType.getValue();
        orderStatus.setValue("");
        var url = "orders_find_order_status.do?keyType=" + keyName
        orderStatus.setUrl(url);
        orderStatus.select(0);
    } 
</script>
</body>
</html>